Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

Addressed 7 critical issues in the v1 fragmentation implementation identified during PR #503 review. These fixes improve protocol safety and clarify known limitations while v2 integration proceeds.

Changes

Fragment validation (fragmentation.rs)

  • Added bounds check: fragment_index < total_fragments in FragmentHeader::from_bytes()
  • Prevents processing of malformed fragments that could corrupt reassembly

Collision risk documentation (fragmentation.rs)

  • Documented non-cryptographic message ID generation (wrapping_sum) with explicit collision scenarios
  • Added inline warnings and migration path to v2's session-scoped IDs

Wire format compatibility (gatt.rs)

  • Documented breaking change: 12-byte headers (u64 message_id) → 8-byte headers (u32)
  • Clarified fragment_large_message() ignores its message_id parameter (changed to _message_id)
  • Old/new clients cannot interoperate

Stale fragment cleanup (gatt.rs)

  • Changed cleanup_stale_fragments() from clearing ALL pending to logging-only
  • Prevents disruption of concurrent valid reassemblies
  • Documents v1 reassembler limitation and v2 migration path

Backward compatibility (blockchain_sync/mod.rs)

  • Added missing deprecated re-exports: BLE_CHUNK_SIZE, WIFI_CHUNK_SIZE
  • Prevents compile failures in existing code

Reassembly logging (gatt.rs)

  • Removed misleading pending_count() call after message completion (always returns 0 or unrelated count)

Example

// Fragment validation now catches malformed data
let mut invalid_bytes = [0u8; 8];
invalid_bytes[4..6].copy_from_slice(&10u16.to_le_bytes());  // total_fragments = 10
invalid_bytes[6..8].copy_from_slice(&10u16.to_le_bytes());  // fragment_index = 10 (invalid)

let result = FragmentHeader::from_bytes(&invalid_bytes);
// Now returns: Err("Invalid fragment: index 10 >= total_fragments 10")

All v1 limitations are now clearly documented with migration guidance to fragmentation_v2.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https --64 -o /home/REDACTED/work/The-Sovereign-Network/The-Sovereign-Network/target/debug/build/zstd-sys-13a73f0058a5149a/out/7faed3f8272f2313-huf_decompress_amd64.o /tmp/ccMfxZKG.s stup/toolchains/-g reign-Network/ta-gdwarf-4 /index.crates.io-fno-omit-frame-pointer /tmp/ccrZIyCb.s artifacts,future-W -w den ons Network/The-Sovezstd/lib/common rget/debug/build-I /usr/local/bin/czstd/lib/legacy --build-id fse_decompress.o-W _script_build-12-I _script_build-12zstd/lib/ (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update MTU constants and fragmentation logic fix: address fragmentation v1 protocol violations and documentation gaps Jan 12, 2026
Copilot AI requested a review from umwelt January 12, 2026 18:10
@umwelt umwelt marked this pull request as ready for review January 12, 2026 18:21
@umwelt umwelt merged commit 781d343 into fix/standardize-mtu-handling-across-protocols Jan 12, 2026
@umwelt umwelt deleted the copilot/sub-pr-503 branch January 12, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants